package main.java.FSMDE.models;

import java.util.UUID;

import main.java.ERMDE.models.INameable;
import main.java.ERMDE.models.IStrongEntity;


public class Component implements INameable, IStrongEntity {

	private String name;
	private UUID id;
	private ComponentType type;
	private String genericTypeName;
	private ErmFsmRelationSet ermRelation = null;

	public static Component create(String componentName,
			ComponentType componentType) {
		return FactoryComponent.create(componentName, componentType);
	}

	public Component(UUID componentId, String componentName,
			ComponentType componentType) {
		name = componentName;
		id = componentId;
		type = componentType;
		genericTypeName = "";
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public UUID getId() {
		return id;
	}

	public void setId(UUID id) {
		this.id = id;
	}

	public ComponentType getType() {
		return type;
	}

	public void setType(ComponentType type) {
		this.type = type;
	}

	@Override
	public String toString() {
		String relationship = "";
		if (ermRelation != null) {
			relationship = " [" + ermRelation.getDiagram().getName() + " "
					+ ermRelation.getEntity().getName() + " "
					+ ermRelation.getAttribute().getName() + "]";

		}
		String typename = this.type.toString();
		if (this.genericTypeName != "")
			typename = this.type + " " + '"' + this.genericTypeName + '"';
		return this.name + " : " + typename + relationship;
	}

	public boolean isComplex() {
		return false;
	}

	public void setGenericType(String genericTypeName) {
		this.genericTypeName = genericTypeName;
	}

	public String getGenericType() {
		return genericTypeName;
	}

	public void showRelationWithErmDiagram(ErmFsmRelationSet relation) {
		this.ermRelation = relation;
	}
}
